package com.weishi.project.training.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.weishi.framework.aspectj.lang.annotation.Log;
import com.weishi.framework.aspectj.lang.enums.BusinessType;
import java.util.Arrays;
import com.weishi.project.training.domain.RaceData;
import com.weishi.project.training.service.IRaceDataService;
import com.weishi.framework.web.controller.BaseController;
import com.weishi.framework.web.domain.AjaxResult;
import com.weishi.common.utils.poi.ExcelUtil;
import com.weishi.framework.web.page.TableDataInfo;

/**
 * 赛后数据表
 */
@RestController
@RequestMapping("/training/raceData")
public class RaceDataController extends BaseController {

    /**
     * 赛后数据表接口
     */
    @Autowired
    private IRaceDataService raceDataService;


    /**
     * 查询赛后数据表列表
     */
    @PreAuthorize("@ss.hasPermi('training:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(RaceData raceData) {
        startPage();
        List<RaceData> list = raceDataService.selectRaceDataList(raceData);
        return getDataTable(list);
    }

    /**
     * 导出赛后数据表列表
     */
    @PreAuthorize("@ss.hasPermi('training:data:export')")
    @Log(title = "赛后数据表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RaceData raceData) {
        List<RaceData> list = raceDataService.selectRaceDataList(raceData);
        ExcelUtil<RaceData> util = new ExcelUtil<RaceData>(RaceData.class);
        return util.exportExcel(list, "data");
    }

    /**
     * 获取赛后数据表详细信息
     */
    @PreAuthorize("@ss.hasPermi('training:data:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(raceDataService.getById(id));
    }

    /**
     * 新增赛后数据表
     */
    @PreAuthorize("@ss.hasPermi('training:data:add')")
    @Log(title = "赛后数据表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RaceData raceData) {
        raceDataService.save(raceData);
        return AjaxResult.success();
    }

    /**
     * 修改赛后数据表
     */
    @PreAuthorize("@ss.hasPermi('training:data:edit')")
    @Log(title = "赛后数据表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RaceData raceData) {
        raceDataService.updateById(raceData);
        return AjaxResult.success();
    }

    /**
     * 删除赛后数据表
     */
    @PreAuthorize("@ss.hasPermi('training:data:remove')")
    @Log(title = "赛后数据表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        raceDataService.removeByIds(Arrays.asList(ids));
        return AjaxResult.success();
    }







}